<template>
  <div class="order">
    <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="全部订单" name="first" :key="'first'">
        <AllOrder v-if="isFirst"></AllOrder>
      </el-tab-pane>
      <el-tab-pane lazy label="待发货" name="second" :key="'second'">
        <UnshipOrder v-if="isSecond"></UnshipOrder>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import AllOrder from "@/components/order/AllOrder.vue";
import UnshipOrder from "@/components/order/UnshipOrder.vue";

export default {
  data() {
    return {
      activeName: "first",
      isFirst: true,
      isSecond: false
    };
  },
  components: {
    UnshipOrder,
    AllOrder
  },
  methods: {
    handleClick(tab) {
      if (tab.name === "first") {
        this.isFirst = true;
        this.isSecond = false;
      } else if (tab.name === "second") {
        this.isFirst = false;
        this.isSecond = true;
      }
    }
  }
};
</script>

<style scoped>
.el-pagination {
  text-align: center;
  margin: 10px 0px 20px 0px;
}
</style>